﻿//Preview
this.imagePreview = function(){ 
        xOffset = 250;
        yOffset = 30;
    $("a.preview").hover(function(e){
        this.t = this.title;
        this.title = "";          var c = (this.t != "") ? "<br/>" + this.t : "";
        $("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");                               
        $("#preview")
            .css("top",(e.pageY - xOffset) + "px")
            .css("left",(e.pageX + yOffset) + "px")
            .fadeIn("fast");                       
    },
    function(){
        this.title = this.t;  
        $("#preview").remove();
    });
    $("a.preview").mousemove(function(e){
        $("#preview")
            .css("top",(e.pageY - xOffset) + "px")
            .css("left",(e.pageX + yOffset) + "px");
    });         
};
//End ImagePreview


$(document).ready(function(){
    //ImagePreview
    imagePreview();

    //MENU
    $("li.menuelement").mouseenter(function(){  
        $(this).parent().find("ul.submenu").hide();
        var $submenu = $(this).find("ul.submenu:first");
        $submenu.stop(true,true);
        $submenu.show('slide','fast');
        $(this).mouseleave(function(){
            $(this).parent().find("ul.submenu").hide();             
        });
        $submenu.mouseleave(function(){
            $(this).parent().find("ul.submenu").hide();             
        });
        return false;
    });
     
    //NEWS  
    $("#news").mouseenter(function(){
        $("#newscontent").stop(true,true);
        $("#newscontent").slideDown('slow');
        $(this).mouseleave(function(){
            $("#newscontent").slideUp('slow');
       });
       return false;
    });
    
    //LOGO
    $(window).load(function(){
        var $lefty = $("#logo");
        $lefty.animate({left: parseInt($lefty.css('left'),10) == 0 ? -$lefty.outerWidth() : 0});        
        $lefty.effect("bounce", { times:3, direction:"left",distance:"10"}, 400);
    });  
    
    //TABS    
  	//When page loads...
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	$(".vtc_smalltab .tabhead").click(function(){
	    $(this).next().find("ul.tabs li").removeClass("active");
	    $(this).next().find(".tab_content").hide();
	    $(this).next().find("ul.tabs li:first").addClass("active").show();
	    $(this).next().find(".tab_content:first").show();
	});

	//On Click Event
	$("ul.tabs li").click(function() {
        
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	}); 
	
	
});

//TEAM PAGE
$(function() {
    $( "#accordion" ).accordion({ animated: false });
	$( "#accordion" ).accordion({ collapsible: true });
	$( "#accordion" ).accordion("activate",false);
	$( "#accordion" ).accordion({ animated: true });   
});
